﻿using AspNetCoreAbp.Domains.Models;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Domain.Repositories;

namespace AspNetCoreAbp.Controllers;

[ApiController]
[Route("api/[controller]")]
public class OrderController : ControllerBase
{
    private readonly IRepository<Order,Guid> _orderRepository;

    public OrderController(IRepository<Order, Guid> orderRepository)
    {
        _orderRepository = orderRepository;
    }

    [HttpGet]
    public async Task<List<Order>> GetListAsync()
    {
        return await _orderRepository.GetListAsync();
    }

    [HttpPost]
    public async Task<Order> CreateAsync(string name)
    {
        return await _orderRepository.InsertAsync(new Order()
        {
            Name = name
        });
    }
}